import { request } from "@/network/request";
// 样例,会了就删了
export function getMessage(goods) {
  return request({
    method: "POST", // 发送方法 GET POST DELETE PUT
    url: "/home/data", // url地址后缀完整的在外部
    params: {
      goodsId: goods.goodsId,
      goodsTitle: goods.goodsTitle,
      goodsInfo: goods.goodsInfo,
      price: Number.parseFloat(goods.price),
      goodsImg: goods.goodsImg,
      goodsNum: goods.goodsNum
    },
    headers: {
      // 头文件封装
      Authorization: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "application/json"
    }
  });
}
/// 鄢雨濛
//创建订单
export function createOrder(obj) {
  return request({
    baseURL: "/apiorder",
    method: "POST",
    url: "order/createOrder",
    data: JSON.stringify(obj),
    headers: {
      Authorization: sessionStorage.getItem("userToken"),
      "Content-Type": "application/json"
    }
  });
}
//根据sku获取价格productSku/getSku
export function getSku(obj) {
  return request({
    baseURL: "/apiproduct",
    method: "POST",
    url: "product/productSku/getSku",
    data: JSON.stringify(obj),
    headers: {
      Authorization: sessionStorage.getItem("userToken"),
      "Content-Type": "application/json"
    }
  });
}
// 获取所有商品
export function getProduct() {
  return request({
    baseURL: "/apiproduct",
    method: "GET",
    url: "product/product/getAllProducts",
    headers: {
      "Content-Type": "application/json"
    }
  });
}

// 通过id获取商品
export function getProductById(id) {
  return request({
    baseURL: "/apiproduct",
    method: "GET",
    url: `product/product/getProductById/${id}`,
    headers: {
      "Content-Type": "application/json"
    }
  });
}
//获取商品预览小图
export function getProImage(id) {
  return request({
    baseURL: "/apiproduct",
    method: "GET",
    url: `product/productImage/getProductImageByProductId/${id}`,
    headers: {
      "Content-Type": "application/json"
    }
  });
}

//获取商品详情图
export function getDetailImage(id) {
  return request({
    baseURL: "/apiproduct",
    method: "GET",
    url: `product/productDetailImage/getAllDetailImage/${id}`, // url地址后缀完整的在外部
    headers: {
      "Content-Type": "application/json"
    }
  });
}
//获取所有分类
export function getAllCategory() {
  return request({
    baseURL: "/apiproduct",
    method: "GET",
    url: "product/productCategory/getAllCategory",
    headers: {
      "Content-Type": "application/json"
    }
  });
}
//根据主键获取商品分类getCategoryOne
export function getCategoryOne(categoryId) {
  return request({
    baseURL: "/apiproduct",
    method: "GET",
    url: `product/productCategory/getCategoryOne/${categoryId}`,
    headers: {
      "Content-Type": "application/json"
    }
  });
}
//根据商品id获取choice
export function getChoice(id) {
  return request({
    baseURL: "/apiproduct",
    method: "GET",
    url: `product/productChoice/getChoice/${id}`,
    headers: {
      Authorization: sessionStorage.getItem("userToken"),
      "Content-Type": "application/json"
    }
  });
}
//获取所有顶级分类
export function getFirstCategory() {
  return request({
    baseURL: "/apiproduct",
    method: "GET",
    url: "product/productCategory/getFirstCategory",
    headers: {
      "Content-Type": "application/json"
    }
  });
}
//获取二级分类
export function getSonCategory(id) {
  return request({
    baseURL: "/apiproduct",
    method: "GET",
    url: `product/productCategory/getSonCategory/${id}`,
    headers: {
      Authorization: sessionStorage.getItem("userToken"),
      "Content-Type": "application/json"
    }
  });
}
//根据分类查询相应商品
export function getAllProductByCategoryId(id) {
  return request({
    baseURL: "/apiproduct",
    method: "GET",
    url: `/product/product/getAllProductByCategoryId/${id}`,
    headers: {
      Authorization: sessionStorage.getItem("userToken"),
      "Content-Type": "application/json"
    }
  });
}

/**
 * @function 获取商品最大ID
 */
export function getMaxIdOfProduct() {
  return request({
    baseURL: "/apiproduct",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: "/product/product/getMaxId",
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "application/json"
    }
  });
}

// 陈燕霞
export function PublishInformation(obj) {
  return request({
    baseURL: "/msglen",
    method: "POST", // 发送方法 GET POST DELETE PUT
    url: "/donation/base/save", // url地址后缀完整的在外部
    params: obj,
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "application/json"
    }
  });
}
// 修改基本信息
/***
 * @author 陈燕霞
 */
export function updateBaseInfo(obj) {
  return request({
    baseURL: "/msglen",
    method: "PUT", // 发送方法 GET POST DELETE PUT
    url: "/donation/base/update", // url地址后缀完整的在外部
    params: obj,
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "application/json"
    }
  });
}
/**
 * @author DJG
 * @function 查询指定学生编号的获奖信息
 * @param {string} recipientId
 * @returns axios实例
 */
export function getAwardIndoByRid(recipientId) {
  return request({
    baseURL: "/msglen",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: "/donation/award/getlistbyrid/" + recipientId, // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "application/json"
    }
  });
}

/**
 * @function 查询指定id编号的荣誉信息
 *@author 代季盖
 * @param {String} awardId 学生编号
 * @returns axios实例
 */
export function getStuAwardByAid(awardId) {
  return request({
    baseURL: "/msglen",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: "/donation/award/info/" + awardId,
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "application/json"
    }
  });
}
// 修改获奖信息
export function updateAward(formData) {
  return request({
    baseURL: "/msglen",
    method: "PUT", // 发送方法 GET POST DELETE PUT
    url: "/donation/award/update", // url地址后缀完整的在外部
    data: formData,
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "application/json"
    }
  });
}
// 修改学习情况
export function updateLearn(obj) {
  return request({
    baseURL: "/msglen",
    method: "PUT", // 发送方法 GET POST DELETE PUT
    url: "/donation/learn/update", // url地址后缀完整的在外部
    params: obj,
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "application/json"
    }
  });
}
// 修改其他信息
export function updateOther(formData) {
  return request({
    baseURL: "/msglen",
    method: "PUT", // 发送方法 GET POST DELETE PUT
    url: "/donation/othersinformationdonation/update", // url地址后缀完整的在外部
    data: formData,
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "application/json"
    }
  });
}
//回馈
export function feedbackInformation(formdata) {
  return request({
    baseURL: "/msglen",
    method: "POST", // 发送方法 GET POST DELETE PUT
    url: "/donation/feedbackinformation/save", // url地址后缀完整的在外部
    data: formdata,
    headers: {
      // 头文件封装
      Authorization: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "multipart/form-data;"
    }
  });
}

// 代季盖
/**
 * @author 代季盖
 * 上传学生荣誉信息
 * @param prizeForm {Object} 上传的表单内容
 */
export function uploadPrize(formData) {
  return request({
    timeout: 10000,
    baseURL: "/msglen",
    method: "POST",
    url: "/donation/award/save",
    data: formData,
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "multipart/form-data"
    }
  });
}
/**
 * @author 代季盖
 * @function publisStudyInfo上传学生学况信息
 * @param {Object}} obj 学生学况信息
 * @returns axios实例
 */
export function publisStudyInfo(obj) {
  return request({
    baseURL: "/msglen",
    method: "POST", // 发送方法 GET POST DELETE PUT
    url: "/donation/learn/save", // url地址后缀完整的在外部
    params: obj,
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "application/json"
    }
  });
}
uploadOtherInfo;
/**
 * @author 代季盖
 * 上传学生其它信息
 * @param formData {Object} 上传的表单内容
 */
export function uploadOtherInfo(formData) {
  return request({
    timeout: 10000,
    baseURL: "/msglen",
    method: "POST",
    url: "/donation/othersinformationdonation/save",
    data: formData,
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "multipart/form-data"
    }
  });
}
/**
 *@author 代季盖
 * @param {String} type 学生类型
 * @param {type} page 得到分页数据
 * @returns axios实例
 */
export function getPageData(type) {
  return request({
    baseURL: "/msglen",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: "/donation/base/getPageSize/" + type, // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "application/json"
    }
  });
}
/**
 *@author 代季盖
 * @param {String} type 学生类型
 * @param {page} page 分页查询页码
 * @returns axios实例
 */
export function getStudentList(type, currentPage) {
  return request({
    baseURL: "/msglen",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: "/donation/base/getListByType/" + type + "/" + currentPage, // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "application/json"
    }
  });
}
/**
 *@author 代季盖
 *@function 查询指定其他信息编号的学生其他信息
 * @param {String} othersId 学生编号
 * @returns axios实例
 */
export function getStuOtherInfoById(othersId) {
  return request({
    baseURL: "/msglen",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: "/donation/othersinformationdonation/info/" + othersId, // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken")
      // 格式设置
    }
  });
}
/**
 *@author 代季盖
 *@function 查询指定id的学生基本信息
 * @param {String} recipientId 学生编号
 * @returns axios实例
 */
export function getStuBaseInfoById(recipientId) {
  return request({
    baseURL: "/msglen",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: "/donation/base/info/" + recipientId, // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken")
      // 格式设置
    }
  });
}
/**
 *@author 代季盖
 *@function 查询指定学生id的学生学习信息
 * @param {String} recipientId 学生编号
 * @returns axios实例
 */
export function getStudyInfo(recipientId) {
  return request({
    baseURL: "/msglen",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: "/donation/learn/getlist/" + recipientId, // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "application/json"
    }
  });
}
/**
 *@author 代季盖
 *@function 查询指定成绩id的学生学习信息
 * @param {String} recipientId 学生编号
 * @returns axios实例
 */
export function getStudyInfoByLsId(lsid) {
  return request({
    baseURL: "/msglen",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: "/donation/learn/info/" + lsid, // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "application/json"
    }
  });
}
/**
 * @function 查询指定id学生的其他信息
 *@author 代季盖
 * @param {String} recipientId 学生编号
 * @returns axios实例
 */
export function getOtherInfoByRid(recipientId) {
  return request({
    baseURL: "/msglen",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: "/donation/othersinformationdonation/getByRid/" + recipientId,
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "application/json"
    }
  });
}
/**
 * @function 支付成功改变订单状态
 * @param {string} orderId 订单编号
 * @axios 实例
 */
export function changeOrderStatus(orderId) {
  return request({
    baseURL: "/apiorder",
    method: "PUT",
    url: "/order/changePayStatus/" + orderId,
    data: { status: 1 },
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "application/json"
    }
  });
}
/**
 * @function 查询支付订单的支付状态
 * @param {string} payId 支付订单号
 */
export function isPay(payId) {
  return request({
    baseURL: "/api",
    method: "POST",
    url: "/sys/api/querypay?id=" + payId,
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "application/json"
    }
  });
}
